<?php

function smarty_function_breadcrumbs($params, &$smarty)
{
    $breadcrumbsStr = "";
    $arrBreadcrumbs = Yii::app()->controller->breadcrumbs;
    //if (count($arrBreadCrumbs) > 0)
    //{
        foreach($arrBreadcrumbs as $title => $url)
        {
            $breadcrumbsStr .= getBreadcrumbsPath($title, $url);
        }
        return $breadcrumbsStr;
    //}    
}

function getBreadcrumbsPath($title, $url)
{
    define("AHREF_PATTERN", "<a href='###url###' title='###title###'>###title###</a>");
    define("SPAN_PATTERN","<span>###title###</span>");
    define("DELIM", " &raquo; ");

    $pattern = "";
    if ($url != "")
    {
        $pattern = AHREF_PATTERN . DELIM;
    }
    else
    {
        $pattern = SPAN_PATTERN;
    }

    $search = array("/###url###/", "/###title###/");
    $replace = array($url, $title);
    return preg_replace($search, $replace, $pattern);
}

?>